package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingDto;
import com.zzyl.service.ServeManagementService;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.PageNursingVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 服务管理
 */
@RestController
@RequestMapping("/nursing_project")
@Api(tags = "服务管理")
public class ServeManagementController extends BaseController {
    private final ServeManagementService service;

    public ServeManagementController(ServeManagementService service) {
        this.service = service;
    }



    /**
     * 护理模块分页查询
     */
    @GetMapping()
    @ApiOperation(value = "护理模块分页查询")
    public ResponseResult PageNursing(@RequestParam(required = false) String name,
                                      @RequestParam(defaultValue = "1") Integer pageNum,
                                      @RequestParam(defaultValue = "10") Integer pageSize,
                                      @RequestParam(required = false) Integer status) {
        PageResponse<PageNursingVO> page = service.PageNursing(name, pageNum, pageSize, status);
        return ResponseResult.success(page);
    }

    /**
     * 添加护理项目
     *
     * @param dto 护理项目
     * @return 成功
     */
    @PostMapping()
    public ResponseResult insertNuringProject(@RequestBody NursingDto dto) {
        service.insertNuringProject(dto);
        return ResponseResult.success();
    }

    /**
     * 查询护理项目
     * @param id 护理项目id
     * @return 成功
     */
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> selectById(@PathVariable("id") Long id) {
        return success( service.selectById(id));
    }

    /**
     * 修改护理项目
     * @param dto 护理项目
     * @return 成功
     */
    @PutMapping
    public ResponseResult updateNuringProject(@RequestBody NursingDto dto) {

        return success( service.updateNuringProject(dto));
    }

    /**
     * 修改护理项目状态
     * @param id 护理项目id
     * @param status 状态
     * @return 成功
     */
    @PutMapping("/{id}/status/{status}")
    public ResponseResult statusNuringProject(@PathVariable("id") Long id,@PathVariable("status") Integer status){
        service.updateNuringProjectStatus(id,status);
        return success( );
    }

    /**
     * 删除护理项目
     * @param id 护理项目id
     * @return 成功
     */
    @DeleteMapping("/{id}")
    public  ResponseResult deleteNuringProject(@PathVariable("id") Long id){
        service.deleteNuringProject(id);
        return success();
    }

    @GetMapping("/select")
    public ResponseResult<List<NursingProjectVo>> SelectNursingProject(){
        return success(service.SelectNursingProject());
    }
}
